/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package helper;

import dbconnector.DBDriver;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author HONEY
 */
public class SeekerHelper
{
   
    public static AO.Seeker getSeekerBean(String username, String password)
{
    try{
         PreparedStatement p= DBDriver.getPrepare("select * from seekerdetails where username=? and password=?");
         p.setString(1, username);
         p.setString(2, password);
         ResultSet rs=p.executeQuery();
         if(rs.next())
         {
                AO.Seeker s=new AO.Seeker();
                 s.setFname(rs.getString("fname"));
                 s.setLname(rs.getString("lname"));
                 s.setDob(rs.getString("dob"));
                 s.setAddress(rs.getString("address"));
                 s.setGender(rs.getString("gender"));
                 s.setStatus(rs.getString("status"));
                 s.setEmail(rs.getString("email"));
                 s.setContact(rs.getString("contact"));
                 s.setUsername(rs.getString("username"));
                 s.setPassword(rs.getString("password"));
                 
                 return s;

        }          
    }
        catch(Exception e){e.printStackTrace();}
        return null;
    
}
    public static boolean updateStatus(String status,String username)
    {
        try
        {
            PreparedStatement p= DBDriver.getPrepare("update seekerdetails set status=? where username=?");
         p.setString(1, status);
         p.setString(2, username);
         int i=p.executeUpdate();
        if (i==1)
            return true;
        return false;
        }
        catch(Exception e){e.printStackTrace(); return false;}
    }
}
